
CPPFLAGS = -g -Wno-non-template-friend
CFLAGS = -g

IMPACT_BUILD=/home/ws/software/openimpact-build/

CSUB_DIR= ./
CSUB_DIR+= annotate/ 
CSUB_DIR+= share/
CXXSUB_DIR=cg/
CXXSUB_DIR+=LcodeConv/
CXXSUB_DIR+=target/
CXXSUB_DIR+=share/
CXXSUB_DIR+=driver/

VPATH=$(CSUB_DIR)
VPATH+=$(CXXSUB_DIR)

SOURCES=$(foreach sub, $(CSUB_DIR) , $(wildcard $(sub)/*.c))
CXXSOURCES=$(foreach sub, $(CXXSUB_DIR), $(wildcard $(sub)/*.cpp))

COBJ=$(patsubst   %, Debug/%, $(notdir $(SOURCES:.c=.o)))
CXXOBJ+=$(patsubst %, Debug/%, $(notdir $(CXXSOURCES:.cpp=.o)))

#COBJ=$(notdir $(SOURCES:.c=.o))
#CXXOBJ=$(notdir $(CXXSOURCES:.cpp=.o))

INC=$(IMPACT_BUILD)/include/

#depend static library
DLD= -L\
        $(IMPACT_BUILD)/lib/liblopti.a \
        $(IMPACT_BUILD)/lib/libblock.a \
        $(IMPACT_BUILD)/lib/libsm.a \
        $(IMPACT_BUILD)/lib/liblmdes.a \
        $(IMPACT_BUILD)/lib/libregalloc.a \
        $(IMPACT_BUILD)/lib/libmarkpipe.a \
        $(IMPACT_BUILD)/lib/liblcode.a \
        $(IMPACT_BUILD)/lib/libbdd.a \
        $(IMPACT_BUILD)/lib/libmspec.a \
        $(IMPACT_BUILD)/lib/libimpact.a \
        -lm

all: $(COBJ) $(CXXOBJ)
	 $(CC) $(CFLAGS) -o Debug/test -g $(COBJ) $(CXXOBJ) $(DLD) -lstdc++
	
$(COBJ):Debug/%.o:%.c
	$(CC) $(CFLAGS) -c -g $< -o $@  -I $(INC) 
$(CXXOBJ):Debug/%.o:%.cpp
	$(CXX) $(CPPFLAGS) -c  -g $< -o $@ -I $(INC) 
	
clean:
	rm Debug/*.o
